//
//  RMMJiaDanTuiJianTableViewCell.m
//  Romomo
//
//  Created by puman on 2017/2/17.
//  Copyright © 2017年 mazegong. All rights reserved.
//

#import "RMMJiaDanTuiJianTableViewCell.h"

@implementation RMMJiaDanTuiJianTableViewCell
{
    UIImageView *_imageV;
    UILabel *_nameLabel;
    UILabel *_qtyLabel;
    UILabel *_timeLabel;
    UILabel *_priceLabel;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _cellSelectBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _cellSelectBut.frame = CGRectMake(0, 10, 60, 60);
        [_cellSelectBut setImage:[UIImage imageNamed:@"可选@2x"] forState:(UIControlStateNormal)];
        [self.contentView addSubview:_cellSelectBut];
        
        _imageV = [[UIImageView alloc] initWithFrame:CGRectMake(_cellSelectBut.right, 10, 60, 60)];
        _imageV.layer.masksToBounds = YES;
        _imageV.layer.cornerRadius = 5;
        [self.contentView addSubview:_imageV];
        
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(_imageV.right + kRow, _imageV.top, kScreenWideth - _imageV.right - 125, kMaric)];
        _nameLabel.font = kFont(14);
        _nameLabel.textColor = COLORFROMCODE(0x303137, 1);
        [self.contentView addSubview:_nameLabel];
        
        _priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWideth - 115, _imageV.top, 100, kMaric)];
        _priceLabel.font = kFont(14);
        _priceLabel.textAlignment = NSTextAlignmentRight;
        _priceLabel.textColor = COLORFROMCODE(0x303137, 1);
        [self.contentView addSubview:_priceLabel];
        
        _qtyLabel = [[UILabel alloc] initWithFrame:CGRectMake(_imageV.right + kRow, _nameLabel.bottom, kScreenWideth - _imageV.right - 25, 12)];
        _qtyLabel.font = kFont(12);
        _qtyLabel.text = @"数量1";
        _qtyLabel.textColor = COLORFROMCODE(0xA0A5A7, 1);
        [self.contentView addSubview:_qtyLabel];

        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(_imageV.right + kRow, _imageV.bottom - 12, kScreenWideth - _imageV.right - 25, 12)];
        _timeLabel.font = kFont(12);
        _timeLabel.textColor = COLORFROMCODE(0xA0A5A7, 1);
        [self.contentView addSubview:_timeLabel];
    }
    return self;
}
- (void)setModel:(RMMHomeGoodsModel *)model{
    [_imageV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kBaseImageUrl,model.IMAGEURL]] placeholderImage:[UIImage imageNamed:@"加载中@3x"]];
    _nameLabel.text = model.NAME;
    _timeLabel.text = [NSString stringWithFormat:@"服务时间 %@ 分钟",model.TIME_LEN];
    _qtyLabel.text = [NSString stringWithFormat:@"数量%@",model.COUNT];
    _priceLabel.text = [NSString stringWithFormat:@"¥ %@",model.PRICE];
    CGFloat width = [UILabel backHeightWithString:_priceLabel.text CGFloatCount:20 metho:WIDTH font:14];
    _priceLabel.frame = CGRectMake(kScreenWideth - width - 20, _imageV.top, width + 5, kMaric);
    _nameLabel.frame = CGRectMake(_imageV.right + kRow, _imageV.top, kScreenWideth - _imageV.right - 20 - width - 10, kMaric);
    if ([model.isSelcet isEqualToString:@"0"]) {
        [_cellSelectBut setImage:[UIImage imageNamed:@"可选@2x"] forState:(UIControlStateNormal)];
    } else {
        [_cellSelectBut setImage:[UIImage imageNamed:@"选中@3x"] forState:(UIControlStateNormal)];
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
